package com.mtask.task.core.action.impl;


import com.mtask.common.entity.task.CallbackJob;
import com.mtask.common.entity.task.TaskJobLog;
import lombok.Getter;
import lombok.Setter;

@Setter
@Getter
public class CallbackTaskAction extends AbstractTaskAction<CallbackJob> {

    @Override
    public void start() {
        if (actionService.callback(referenceJob.getLink())) {
            System.out.println("回调成功");
        } else {
            System.out.println("回调失败");
        }
    }

    @Override
    public void beforeStart() {
        // TODO document why this method is empty
    }

    @Override
    public void afterStart() {
        TaskJobLog entity = new TaskJobLog();
        entity.setJobId(referenceJob.getTaskJobId());
        entity.setLink(referenceJob.getLink());
        entity.setStatus(task.getStatus());
        entity.setReferenceType(task.getReferenceType());
        taskJobLogRepository.save(entity);
    }

}
